<template>
  <div class="listview-header">
    <!-- 背景图片 -->
    <img class="bg" :src="playlist.coverImgUrl" />

    <!-- 头部导航栏 -->
    <div class="header-nav">
      <!-- 返回按钮 -->
      <div class="back">
        <svg class="icon icon-left" aria-hidden="true" @click="$router.go(-1)">
          <use xlink:href="#icon-arrowLeft" />
        </svg>
        <div class="title">歌单</div>
      </div>

      <div class="right">
        <svg class="icon" aria-hidden="true">
          <use xlink:href="#icon-search" />
        </svg>
        <svg class="icon icon-more" aria-hidden="true">
          <use xlink:href="#icon-more" />
        </svg>
      </div>
    </div>

    <!-- 歌单介绍 -->
    <div class="header-detail">
      <div class="detail-left">
        <img :src="playlist.coverImgUrl" />
        <div class="playcount">
          <svg class="icon" aria-hidden="true">
            <use xlink:href="#icon-play" />
          </svg>
          <span>{{changeValue(playlist.playCount)}}</span>
        </div>
      </div>
      <div class="detail-right">
        <h3>{{playlist.name}}</h3>
        <div class="author">
          <img :src="playlist.creator.avatarUrl" class="header-pic" />
          <span>{{playlist.creator.nickname}}</span>
        </div>
        <div class="description">{{playlist.description}}</div>
      </div>
    </div>

    <!-- 操作选项 -->
    <div class="control">
      <div class="control-item">
        <svg class="icon" aria-hidden="true">
          <use xlink:href="#icon-liaotian" />
        </svg>
        <div class="title">{{playlist.commentCount}}</div>
      </div>
      <div class="control-item">
        <svg class="icon" aria-hidden="true">
          <use xlink:href="#icon-fenxiang-m" />
        </svg>
        <div class="title">{{playlist.shareCount}}</div>
      </div>
      <div class="control-item">
        <svg class="icon big" aria-hidden="true">
          <use xlink:href="#icon-yunxiazai_o" />
        </svg>
        <div class="title">下载</div>
      </div>
      <div class="control-item">
        <svg class="icon" aria-hidden="true">
          <use xlink:href="#icon-xianshi_xuanze" />
        </svg>
        <div class="title">多选</div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'ListViewHeader',
  props: ['playlist'],
  methods: {
    changeValue(num) {
      let res = 0
      if (num >= 100000000) {
        res = num / 100000000
        res = res.toFixed(2) + '亿'
      } else if (num >= 10000) {
        res = num / 10000
        res = res.toFixed(2) + '万'
      }
      return res
    }
  }
}
</script>

<style lang="less" scoped>
.listview-header {
  width: 100%;
  font-size: 0.4rem;
  position: relative;

  // 背景图
  .bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: auto;
    filter: blur(25px);
    z-index: -1;
  }

  // 头部导航栏
  .header-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 1.5rem;
    color: #fff;
    .back,
    .right {
      display: flex;
    }
    .icon {
      width: 0.45rem;
      height: 0.45rem;
      fill: #fff;
    }
    .icon-left {
      margin-left: 0.1rem;
      margin-right: 0.4rem;
      width: 0.55rem;
      height: 0.55rem;
    }
    .icon-more {
      margin-left: 0.5rem;
      margin-right: 0.1rem;
    }
  }

  // 歌单介绍
  .header-detail {
    width: 100%;
    height: 3rem;
    display: flex;
    justify-content: space-between;
    .detail-left {
      position: relative;
      width: 40%;
      img {
        width: 100%;
        border-radius: 0.2rem;
      }
      .playcount {
        position: absolute;
        top: 0.1rem;
        right: 0.1rem;
        color: #fff;
        fill: #fff;
        font-size: 0.25rem;
        display: flex;
        align-items: center;
        .icon {
          width: 0.2rem;
          margin-right: 0.05rem;
        }
      }
    }
    .detail-right {
      width: 55%;
      color: white;
      h3 {
        font-size: 0.4rem;
        overflow: hidden;
        text-overflow: ellipsis;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        font-weight: 900;
      }
      .author {
        display: flex;
        align-items: center;
        padding-top: 0.2rem;
        padding-bottom: 0.2rem;
        .header-pic {
          width: 0.6rem;
          height: 0.6rem;
          border-radius: 0.3rem;
        }
        span {
          font-size: 0.32rem;
          padding-left: 0.2rem;
        }
      }
      .description {
        font-size: 0.25rem;
        overflow: hidden;
        text-overflow: ellipsis;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
      }
    }
  }

  // 操作选项
  .control {
    padding: 0.4rem 0;
    display: flex;
    justify-content: space-around;
    align-items: center;
    .control-item {
      display: flex;
      flex-direction: column;
      align-items: center;
      color: white;
      fill: white;
      .icon {
        width: 0.5rem;
        height: 0.5rem;
        margin-bottom: 0.1rem;
      }
      .big {
        width: 0.6rem;
        height: 0.57rem;
      }
      .title {
        font-size: 0.25rem;
      }
    }
  }
}
</style>